package com.prd.controller;


import com.prd.dto.OaOfferLetterDTO;
import com.prd.service.OaOfferLetterService;
import com.prd.util.JsonData;
import com.prd.workflow.ProcessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


/**
 * <p>
 * 录用通知书 前端控制器
 * </p>
 *
 * @author lizhaoyi
 * @since 2023-12-24
 */
@RestController
@RequestMapping("/api/oaOfferLetter")
@Api(tags = "录用入职管理")
public class OaOfferLetterController {

    @Autowired
    private OaOfferLetterService oaOfferLetterService;

    @Autowired
    private ProcessService processService;


    @ApiOperation("录用-提交审核")
    @PostMapping("employSubmit")
    public JsonData employSubmit(@RequestBody OaOfferLetterDTO oaOfferLetterDTO){

        return oaOfferLetterService.addOfferLetter(oaOfferLetterDTO);
    }

    @ApiOperation("根据类型查询依据列表")
    @PostMapping("getBasisList")
    public JsonData getBasisListByType(@RequestParam("type") Integer type){

        return oaOfferLetterService.getBasisListByType(type);
    }

    @ApiOperation("导入依据列表")
    @PostMapping("addList")
    public JsonData addBasisList(){

        return null;
    }

    @ApiOperation("录用通知详情")
    @GetMapping("detail")
    public JsonData detail(@ApiParam(value = "录用通知书id") @RequestParam(value ="id") String id){

        return oaOfferLetterService.detail(id);
    }


    @ApiOperation("入职管理列表")
    @GetMapping
    public JsonData getList(){

        return oaOfferLetterService.getList();
    }

    @ApiOperation("录用-审核意见")
    @PostMapping("employViewerAgree")
    public JsonData viewerAgree(@RequestBody OaOfferLetterDTO oaOfferLetterDTO){

        return oaOfferLetterService.viewerAgree(oaOfferLetterDTO);
    }

    @ApiOperation("录用-审核意见-撤销")
    @PostMapping("employViewerCancel")
    public JsonData viewerCancel(@RequestBody OaOfferLetterDTO oaOfferLetterDTO){

        return oaOfferLetterService.viewerCancel(oaOfferLetterDTO);
    }

    @ApiOperation("审核意见详情")
    @PostMapping("employViewDetail")
    public JsonData viewDetail(){

        return null;
    }

    @ApiOperation("录用-批准通过")
    @PostMapping("employApproveAgree")
    public JsonData approveAgree(@RequestBody OaOfferLetterDTO oaOfferLetterDTO){

        return oaOfferLetterService.approveAgree(oaOfferLetterDTO);
    }


    @ApiOperation("录用-批准不通过")
    @PostMapping("employApproveReject")
    public JsonData approveReject(@RequestBody OaOfferLetterDTO oaOfferLetterDTO){

        return oaOfferLetterService.approveReject(oaOfferLetterDTO);
    }

    @ApiOperation("录用-确认入职")
    @PostMapping("employConfirm")
    public JsonData confirm(@RequestBody OaOfferLetterDTO oaOfferLetterDTO){

        return oaOfferLetterService.confirm(oaOfferLetterDTO);
    }

    @ApiOperation("录用-放弃入职")
    @PostMapping("employConfirmGiveUp")
    public JsonData confirmGiveUp(@RequestBody OaOfferLetterDTO oaOfferLetterDTO){

        return oaOfferLetterService.confirmGiveUp(oaOfferLetterDTO);
    }


    @ApiOperation("录用-入职人员报到")
    @PostMapping("employEmployerConfirm")
    public JsonData employerConfirm(@RequestBody OaOfferLetterDTO oaOfferLetterDTO){

        return oaOfferLetterService.employerConfirm(oaOfferLetterDTO);
    }

    @ApiOperation("录用-人事确认-发起入职审批")
    @PostMapping("employHrConfirm")
    public JsonData hrConfirm(@RequestBody OaOfferLetterDTO oaOfferLetterDTO){

        return oaOfferLetterService.hrConfirm(oaOfferLetterDTO);
    }

    @ApiOperation("录用-人事确认-退回")
    @PostMapping("employHrCallback")
    public JsonData callback(@RequestBody OaOfferLetterDTO oaOfferLetterDTO){

        return oaOfferLetterService.callback(oaOfferLetterDTO);
    }

    @ApiOperation("录用-人事确认-撤销")
    @PostMapping("employHrCancel")
    public JsonData cancel(@RequestBody OaOfferLetterDTO oaOfferLetterDTO){

        return oaOfferLetterService.cancel(oaOfferLetterDTO);
    }


    @ApiOperation("入职-审核意见确认上传")
    @PostMapping("entryReview")
    public JsonData entryReview(@RequestBody OaOfferLetterDTO oaOfferLetterDTO){

        return oaOfferLetterService.entryReview(oaOfferLetterDTO);
    }

    @ApiOperation("入职-审核通过")
    @PostMapping("entryApprovePass")
    public JsonData entryApprovePass(@RequestBody OaOfferLetterDTO oaOfferLetterDTO){

        return oaOfferLetterService.entryApprovePass(oaOfferLetterDTO);
    }

    @ApiOperation("入职-审核不通过")
    @PostMapping("entryApproveRefuse")
    public JsonData entryApproveRefuse(@RequestBody OaOfferLetterDTO oaOfferLetterDTO){

        return oaOfferLetterService.entryApproveRefuse(oaOfferLetterDTO);
    }


    @ApiOperation("新增任命书")
    @PostMapping("newBook")
    public JsonData newBook(@RequestBody OaOfferLetterDTO oaOfferLetterDTO){

        return oaOfferLetterService.newBook(oaOfferLetterDTO);
    }

    @ApiOperation("入职-任命书审核意见确认上传")
    @PostMapping("entryBookReview")
    public JsonData entryBookReview(@RequestBody OaOfferLetterDTO oaOfferLetterDTO){

        return oaOfferLetterService.entryBookReview(oaOfferLetterDTO);
    }

    @ApiOperation("入职-任命书审批通过")
    @PostMapping("entryBookApprovePass")
    public JsonData entryBookApprovePass(@RequestBody OaOfferLetterDTO oaOfferLetterDTO){

        return oaOfferLetterService.entryBookApprovePass(oaOfferLetterDTO);
    }


    @ApiOperation("入职-任命书审批驳回")
    @PostMapping("entryBookApproveRefuse")
    public JsonData entryBookApproveRefuse(@RequestBody OaOfferLetterDTO oaOfferLetterDTO){

        return oaOfferLetterService.entryBookApproveRefuse(oaOfferLetterDTO);
    }


    @ApiOperation("入职-人员安排通知单")
    @PostMapping("entryPersonLetter")
    public JsonData entryPersonLetter(@RequestBody OaOfferLetterDTO oaOfferLetterDTO){

        return oaOfferLetterService.entryPersonLetter(oaOfferLetterDTO);
    }

    @ApiOperation("入职-报到")
    @PostMapping("entryPersonCheckIn")
    public JsonData entryPersonCheckIn(@RequestBody OaOfferLetterDTO oaOfferLetterDTO){

        return oaOfferLetterService.entryPersonCheckIn(oaOfferLetterDTO);
    }


    @ApiOperation("入职-确认报到")
    @PostMapping("entryCheckIn")
    public JsonData entryCheckIn(@RequestBody OaOfferLetterDTO oaOfferLetterDTO){

        return oaOfferLetterService.entryCheckIn(oaOfferLetterDTO);
    }



    @ApiOperation("查看工作流程图")
    @GetMapping("showProcessPic")
    public JsonData showProcessPic(HttpServletResponse resp,
                               @ApiParam("工作流id") @RequestParam(value = "processId") String processId) throws IOException {

        return processService.showProcessPic(resp,processId);
    }

}
